<template>
    <div style="z-index: 1;">
        <div class="layout-left"
            :class="{
                'layout-left-collapsed': collapsed
            }"
            :style="`width: ${leftWidth}px`">
            <div class="layout-logo" id="logo">
                <a href="/">
                    <img src="../../assets/logo.svg" alt="logo">
                    <h1>Ant Design Pro</h1>
                </a>
            </div>
            <ul class="layout-menu">
                <li class="menu-item menu-item-selected">
                    <a-icon type="dashboard" />
                    <span>Dashboard</span>
                </li>
                <li class="menu-item">
                    <a-icon type="form" />
                    <span>表单页</span>
                </li>
                <li class="menu-item">
                    <a-icon type="table" />
                    <span>列表页</span>
                </li>
                <li class="menu-submenu">
                    <div class="menu-submenu-title">
                        <a-icon type="profile" />
                        <span>详情页</span>
                        <i class="ant-menu-submenu-arrow"></i>
                    </div>
                    <ul class="menu-sub" style="padding-left: 24px; display: none">
                        <li class="menu-item">基础详情页</li>
                        <li class="menu-item">高级详情页</li>
                    </ul>
                </li>
                <li class="menu-item">
                    <a-icon type="check-circle" />
                    <span>结果页</span>
                </li>
                <li class="menu-item">
                    <a-icon type="warning" />
                    <span>异常页</span>
                </li>
                <li class="menu-item">
                    <a-icon type="user" />
                    <span>个人页</span>
                </li>
                <li class="menu-item">
                    <a-icon type="highlight" />
                    <span>图形编辑器</span>
                </li>
            </ul>
        </div>
        <header class="layout-header" :style="`margin-left: ${leftWidth}px`">
            <div class="global-header-trigger" @click="collapseMenu">
                <a-icon v-if="collapsed" type="menu-fold" />
                <a-icon v-else type="menu-unfold" />
            </div>
        </header>
        <div class="layout-content" :style="`margin-left: ${leftWidth}px`">

        </div>
    </div>
</template>
<script>
export default {
    props: {
        collaps: {
            defult: false,
            type: Boolean
        }
    },
    data () {
        return {
            collapsed: this.collaps
        }
    },
    computed: {
        leftWidth () {
            if (this.collapsed) {
                return 80
            } else {
                return 256
            }
        }
    },
    methods: {
        collapseMenu () {
            this.collapsed = !this.collapsed
        }
    }
}
</script>

<style lang="less">
body .bg {
    // background-image: url(http://pic1.win4000.com/wallpaper/2019-06-11/5cff5434b9ed6.jpg);
    // background-image: url(http://pic1.win4000.com/wallpaper/2020-06-19/5eec349b19ef6.jpg)
    // background-image: url(http://pic1.win4000.com/wallpaper/2020-06-15/5ee6d3afc14c7.jpg);
    // background-image: url(http://pic1.win4000.com/wallpaper/2020-06-11/5ee1c47c3539f.jpg)
}
body.dark {
    .bg {
        background-color: #000
    }
    .layout-left {
        color: #fff;
        background: rgba(255, 255, 255, .12);
    }
}
.layout-logo {
    position: relative;
    padding-left: 24px;
    overflow: hidden;
    cursor: pointer;
    transition: all .3s;
    a {
        display: flex;
        align-items: center;
        height: 64px;
    }
    img {
        display: inline-block;
        height: 32px;
        vertical-align: middle;
    }
    h1 {
        display: inline-block;
        margin: 0 0 0 12px;
        font-weight: 600;
        font-size: 20px;
        vertical-align: middle;
        animation: fade-in;
        animation-duration: .3s;
    }
}
.layout-left {
    background: #fff;
    box-shadow: 2px 0 8px 0 rgba(29,35,41,.05);
    position: absolute;
    width: 256px;
    height: 100%;
    left: 0;
    top: 0;
    .layout-menu {
        padding: 16px 0;
    }
    .anticon {
        margin-right: 10px;
    }
    .menu-item, .menu-submenu-title {
        height: 40px;
        line-height: 40px;
        padding-left: 24px;
        cursor: pointer;
    }
    .menu-item {}
    .menu-submenu-title {}
    .menu-item-selected {
        background: rgba(0, 0, 0, .1)
    }
    &.layout-left-collapsed {
        .layout-logo h1 {
            display: none
        }
        .menu-item, .menu-submenu-title {
            padding-left: 32px;
            span {
                display: none
            }
        }
    }
}
.layout-header {
    height: 64px;
    line-height: 64px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,21,41,.08);
    .global-header-trigger {
        padding: 0 24px;
        font-size: 20px;
        cursor: pointer;
    }
}
.layout-content {
    margin-top: 64px;
}
</style>
